
#ifndef printerlibs_caysnpos_h
#define printerlibs_caysnpos_h

#ifndef PRINTERLIBS_API
#define PRINTERLIBS_API
#endif

#ifdef __cplusplus
extern "C" {
#endif


#ifndef CallbackFunctionOnNetPrinterDiscovered
#define CallbackFunctionOnNetPrinterDiscovered
typedef void (*on_netprinter_discovered_a)(const char *local_ip, const char *discovered_mac, const char *discovered_ip, const char *discovered_name, const void *private_data);
typedef void (*on_netprinter_discovered_w)(const wchar_t *local_ip, const wchar_t *discovered_mac, const wchar_t *discovered_ip, const wchar_t *discovered_name, const void *private_data);
#endif


#ifndef CallbackFunctionOnBluetoothDeviceDiscovered
#define CallbackFunctionOnBluetoothDeviceDiscovered
typedef void (*on_btdevice_discovered_a)(const char *device_name, const char *device_address, const void *private_data);
#endif


#ifndef CallbackFunctionOnBytesReaded
#define CallbackFunctionOnBytesReaded
typedef void (*on_bytes_readed)(const unsigned char *buffer, const unsigned int count, void *private_data);
#endif


#ifndef CallbackFunctionOnBytesWrited
#define CallbackFunctionOnBytesWrited
typedef void (*on_bytes_writed)(const unsigned char *buffer, const unsigned int count, void *private_data);
#endif


#ifndef CallbackFunctionOnPortClosed
#define CallbackFunctionOnPortClosed
typedef void (*on_port_closed)(void *private_data);
#endif


#ifndef MarcoDefinitionQueryBuffer
#define MarcoDefinitionQueryBuffer
#define PL_QUERYBUFFER_EMTPY 0
#define PL_QUERYBUFFER_FAILED_PORT_CLOSED -1
#define PL_QUERYBUFFER_FAILED_PORT_WRITEFAILED -2
#define PL_QUERYBUFFER_FAILED_PORT_READFAILED -3
#define PL_QUERYBUFFER_NOT_EMPTY -4
#endif


#ifndef MarcoDefinitionPrintResult
#define MarcoDefinitionPrintResult
#define PL_PRINTRESULT_SUCCESS 0
#define PL_PRINTRESULT_PORT_CLOSED -1
#define PL_PRINTRESULT_PORT_WRITEFAILED -2
#define PL_PRINTRESULT_PORT_READFAILED -3
#define PL_PRINTRESULT_PRINTER_OFFLINE -102
#define PL_PRINTRESULT_PRINTER_NOPAPER -103
#define PL_PRINTRESULT_OTHER_RERROR -101
#endif


#ifndef MarcoDefinitionPrinterStatus
#define MarcoDefinitionPrinterStatus
#define PL_PRINTERSTATUS_DRAWER_OPENED(status) (((status >> 0) & 0x04) == 0x00)
#define PL_PRINTERSTATUS_OFFLINE(status) (((status >> 0) & 0x08) == 0x08)
#define PL_PRINTERSTATUS_COVERUP(status) (((status >> 8) & 0x04) == 0x04)
#define PL_PRINTERSTATUS_FEED_PRESSED(status) (((status >> 8) & 0x08) == 0x08)
#define PL_PRINTERSTATUS_NOPAPER(status) (((status >> 8) & 0x20) == 0x20)
#define PL_PRINTERSTATUS_ERROR_OCCURED(status) (((status >> 8) & 0x40) == 0x40)
#define PL_PRINTERSTATUS_CUTTER_ERROR(status) (((status >> 16) & 0x08) == 0x08)
#define PL_PRINTERSTATUS_UNRECOVERABLE_ERROR(status) (((status >> 16) & 0x20) == 0x20)
#define PL_PRINTERSTATUS_DEGREE_OR_VOLTAGE_OVERRANGE(status) (((status >> 16) & 0x40) == 0x40)
#define PL_PRINTERSTATUS_PAPER_NEAREND(status) (((status >> 24) & 0x0C) == 0x0C)
#define PL_PRINTERSTATUS_PAPER_TAKEOUT(status) (((status >> 24) & 0x04) == 0x04)
#endif


#ifndef EnumTypePrintDensity
#define EnumTypePrintDensity
typedef enum PrintDensity { PrintDensity_Light, PrintDensity_Normal, PrintDensity_Dark } PrintDensity;
#endif


#ifndef EnumTypePosAlignment
#define EnumTypePosAlignment
typedef enum PosAlignment { PosAlignment_Left, PosAlignment_HCenter, PosAlignment_Right } PosAlignment;
#endif


#ifndef EnumTypeMultiByteModeEncoding
#define EnumTypeMultiByteModeEncoding
typedef enum MultiByteModeEncoding { MultiByteModeEncoding_GBK = 0, MultiByteModeEncoding_UTF8 = 1, MultiByteModeEncoding_BIG5 = 3, MultiByteModeEncoding_ShiftJIS = 4, MultiByteModeEncoding_EUCKR = 5 } MultiByteModeEncoding;
#endif


#ifndef EnumTypeAsciiTextFontType
#define EnumTypeAsciiTextFontType
typedef enum AsciiTextFontType { AsciiTextFontType_A, AsciiTextFontType_B, AsciiTextFontType_C, AsciiTextFontType_D, AsciiTextFontType_E } AsciiTextFontType;
#endif


#ifndef EnumTypeTextUnderline
#define EnumTypeTextUnderline
typedef enum TextUnderline { TextUnderline_None, TextUnderline_One, TextUnderline_Two } TextUnderline;
#endif


#ifndef EnumTypeCharacterSet
#define EnumTypeCharacterSet
typedef enum CharacterSet {
    CharacterSet_USA = 0,
    CharacterSet_FRANCE = 1,
    CharacterSet_GERMANY = 2,
    CharacterSet_UK = 3,
    CharacterSet_DENMARK_I = 4,
    CharacterSet_SWEDEN = 5,
    CharacterSet_ITALY = 6,
    CharacterSet_SPAIN_I = 7,
    CharacterSet_JAPAN = 8,
    CharacterSet_NORWAY = 9,
    CharacterSet_DENMARK_II = 10,
    CharacterSet_SPAIN_II = 11,
    CharacterSet_LATIN = 12,
    CharacterSet_KOREA = 13,
    CharacterSet_SLOVENIA = 14,
    CharacterSet_CHINA = 15
} CharacterSet;
#endif


#ifndef EnumTypeCharacterCodepage
#define EnumTypeCharacterCodepage
typedef enum CharacterCodepage {
    CharacterCodepage_CP437 = 0,
    CharacterCodepage_KATAKANA = 1,
    CharacterCodepage_CP850 = 2,
    CharacterCodepage_CP860 = 3,
    CharacterCodepage_CP863 = 4,
    CharacterCodepage_CP865 = 5,
    CharacterCodepage_WCP1251 = 6,
    CharacterCodepage_CP866 = 7,
    CharacterCodepage_MIK = 8,
    CharacterCodepage_CP755 = 9,
    CharacterCodepage_IRAN = 10,
    CharacterCodepage_CP862 = 15,
    CharacterCodepage_WCP1252 = 16,
    CharacterCodepage_WCP1253 = 17,
    CharacterCodepage_CP852 = 18,
    CharacterCodepage_CP858 = 19,
    CharacterCodepage_IRAN_II = 20,
    CharacterCodepage_LATVIAN = 21,
    CharacterCodepage_CP864 = 22,
    CharacterCodepage_ISO_8859_1 = 23,
    CharacterCodepage_CP737 = 24,
    CharacterCodepage_WCP1257 = 25,
    CharacterCodepage_THAI = 26,
    CharacterCodepage_CP720 = 27,
    CharacterCodepage_CP855 = 28,
    CharacterCodepage_CP857 = 29,
    CharacterCodepage_WCP1250 = 30,
    CharacterCodepage_CP775 = 31,
    CharacterCodepage_WCP1254 = 32,
    CharacterCodepage_WCP1255 = 33,
    CharacterCodepage_WCP1256 = 34,
    CharacterCodepage_WCP1258 = 35,
    CharacterCodepage_ISO_8859_2 = 36,
    CharacterCodepage_ISO_8859_3 = 37,
    CharacterCodepage_ISO_8859_4 = 38,
    CharacterCodepage_ISO_8859_5 = 39,
    CharacterCodepage_ISO_8859_6 = 40,
    CharacterCodepage_ISO_8859_7 = 41,
    CharacterCodepage_ISO_8859_8 = 42,
    CharacterCodepage_ISO_8859_9 = 43,
    CharacterCodepage_ISO_8859_15 = 44,
    CharacterCodepage_THAI_2 = 45,
    CharacterCodepage_CP856 = 46,
    CharacterCodepage_CP874 = 47,
    CharacterCodepage_TCVN3 = 48
} CharacterCodepage;
#endif


#ifndef EnumTypeBarcodeReadableTextFontType
#define EnumTypeBarcodeReadableTextFontType
typedef enum BarcodeReadableTextFontType { BarcodeReadableTextFontType_Standard, BarcodeReadableTextFontType_Small } BarcodeReadableTextFontType;
#endif


#ifndef EnumTypeBarcodeReadableTextPosition
#define EnumTypeBarcodeReadableTextPosition
typedef enum BarcodeReadableTextPosition { BarcodeReadableTextPosition_None, BarcodeReadableTextPosition_AboveBarcode, BarcodeReadableTextPosition_BelowBarcode, BarcodeReadableTextPosition_AboveAndBelowBarcode } BarcodeReadableTextPosition;
#endif


#ifndef EnumTypePosBarcodeType
#define EnumTypePosBarcodeType
typedef enum PosBarcodeType { 
    PosBarcodeType_UPCA = 0x41,
    PosBarcodeType_UPCE = 0x42,
    PosBarcodeType_EAN13 = 0x43,
    PosBarcodeType_EAN8 = 0x44,
    PosBarcodeType_CODE39 = 0x45,
    PosBarcodeType_ITF = 0x46,
    PosBarcodeType_CODEBAR = 0x47,
    PosBarcodeType_CODE93 = 0x48,
    PosBarcodeType_CODE128 = 0x49
} PosBarcodeType;
#endif


#ifndef EnumTypeQRCodeECC
#define EnumTypeQRCodeECC
typedef enum QRCodeECC { QRCodeECC_L = 1, QRCodeECC_M = 2, QRCodeECC_Q = 3, QRCodeECC_H = 4 } QRCodeECC;
#endif


#ifndef EnumTypeImagePixelsFormat
#define EnumTypeImagePixelsFormat
typedef enum ImagePixelsFormat { 
    ImagePixelsFormat_MONO = 1,
    ImagePixelsFormat_MONOLSB = 2,
    ImagePixelsFormat_GRAY8 = 3,
    ImagePixelsFormat_BYTEORDERED_RGB24 = 4,
    ImagePixelsFormat_BYTEORDERED_BGR24 = 5,
    ImagePixelsFormat_BYTEORDERED_ARGB32 = 6,
    ImagePixelsFormat_BYTEORDERED_RGBA32 = 7,
    ImagePixelsFormat_BYTEORDERED_ABGR32 = 8,
    ImagePixelsFormat_BYTEORDERED_BGRA32 = 9
} ImagePixelsFormat;
#endif


#ifndef EnumTypeImageBinarizationMethod
#define EnumTypeImageBinarizationMethod
typedef enum ImageBinarizationMethod { ImageBinarizationMethod_Dithering, ImageBinarizationMethod_Thresholding } ImageBinarizationMethod;
#endif


#ifndef EnumTypeImageCompressionMethod
#define EnumTypeImageCompressionMethod
typedef enum ImageCompressionMethod { ImageCompressionMethod_None, ImageCompressionMethod_Level1, ImageCompressionMethod_Level2 } ImageCompressionMethod;
#endif

//      get library version string
//
//  return
//      return library version string
PRINTERLIBS_API const char *CaysnPos_LibraryVersion(void);

//      Enumerate net printer
//
//  timeout
//      enumrate timeout ms
// 
//  cancel
//      cancel bit, if value is non-zero, enum process will exit.
//  
//  on_discovered
//      enumrated callback function
//
//  private_data
//      the parameter passed to callback function
//
//  return
//      none
PRINTERLIBS_API void CaysnPos_EnumNetPrinterA(unsigned int timeout, int *cancel, on_netprinter_discovered_a on_discovered, const void *private_data);
PRINTERLIBS_API void CaysnPos_EnumNetPrinterW(unsigned int timeout, int *cancel, on_netprinter_discovered_w on_discovered, const void *private_data);

//      Enumerate bt 4.0 printer
//
//  on_discovered
//      enumrated callback function
//
//  private_data
//      the parameter passed to callback function
//
//  return
//      none
PRINTERLIBS_API void CaysnPos_EnumBleDeviceA(unsigned int timeout, int *cancel, on_btdevice_discovered_a on_discovered, const void *private_data);

//      Open Tcp
//
// ip 
//      IP Addres or printer name
//      For example: 192.168.1.87
//
// port 
//      Port Number
//      Fixed value: 9100
//
// timeout
//      connect timeout
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      PC and printer need in the same network segment, so they can connect
PRINTERLIBS_API void * CaysnPos_OpenTcpA(const char *ip, unsigned short port, unsigned int timeout);
PRINTERLIBS_API void * CaysnPos_OpenTcpW(const wchar_t *ip, unsigned short port, unsigned int timeout);

//      specify interface Open Tcp
//
// ip 
//      IP Addres or printer name
//      For example: 192.168.1.87
//
// port 
//      Port Number
//      Fixed value: 9100
//
// bind_local_addr 
//      bind to local ip 
//      if there is multiple network cards, you can specify the item 
//      you can also set 0 to auto select
//
// timeout
//      connect timeout
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      PC and printer need in the same network segment, so they can connect
PRINTERLIBS_API void * CaysnPos_OpenTcpBindInterfaceA(const char *ip, unsigned short port, const char *bind_local_addr, unsigned int timeout);
PRINTERLIBS_API void * CaysnPos_OpenTcpBindInterfaceW(const wchar_t *ip, unsigned short port, const wchar_t *bind_local_addr, unsigned int timeout);

//      Connect Bluetooth4.0 Printer
//
// address 
//      bluetooth address
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      only for android
PRINTERLIBS_API void * CaysnPos_OpenBT4ByConnectA(const char *address);
PRINTERLIBS_API void * CaysnPos_OpenBT4ByConnectW(const wchar_t *address);

//      Connect Bluetooth4.0 Printer
//
// mPeripheral 
//      bluetooth printer device(CBPeripheral)
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      only for ios
PRINTERLIBS_API void * CaysnPos_OpenBT4ByConnectPeripheral(void *mPeripheral);

//      Set Bluetooth4.0 Data write mode
//
// handle 
//      Port handle, returned by OpenXXX
//
// bHighSpeed
//      false: CBCharacteristicWriteWithResponse
//       true: CBCharacteristicWriteWithoutResponse
//
// nPacketSize
//      default value is 20, maybe 120.
//
// nPacketTimeout
//      packet write timeout ms. default is 3600*1000
//
// nPacketMaxRetry
//      packet write retry if failed. default is 3
//
// mPeripheral 
//      bluetooth printer device(CBPeripheral)
//
// return 
//      None
//
// remarks
//      only for ios
PRINTERLIBS_API void CaysnPos_SetBT4WriteMode(void * handle, bool bHighSpeed, unsigned int nPacketSize, unsigned int nPacketTimeout, unsigned int nPacketMaxRetry);

//      Open file
//
// name
//      file name
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      just can write, but can't read
//      All the query status function are invalid
PRINTERLIBS_API void * CaysnPos_OpenFileNewA(const char *name);
PRINTERLIBS_API void * CaysnPos_OpenFileNewW(const wchar_t *name);

//      Open file, the data will append to the file
//
// name
//      file name
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      just can write, but can't read
//      All the query status function are invalid
PRINTERLIBS_API void * CaysnPos_OpenFileAppendA(const char *name);
PRINTERLIBS_API void * CaysnPos_OpenFileAppendW(const wchar_t *name);

//      alloc an memory space, the data will write to the memory
//
// nMemorySpaceSize
//      memory space size
//
// return 
//      Return handle, If open success, return non-zero value, else return zero.
//
// remarks
//      just can write, but can't read
//      All the query status function are invalid
//      data accessed by MemoryData MemoryDataLength
//      data clear by ClearMemoryData
PRINTERLIBS_API void * CaysnPos_OpenMemory(unsigned int nMemorySpaceSize);

//      get memory data
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      memory pointer
//
// remarks
//      none
PRINTERLIBS_API const unsigned char *CaysnPos_MemoryData(void * handle);

//      memory data length
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      memory data length
//
// remarks
//      none
PRINTERLIBS_API unsigned int CaysnPos_MemoryDataLength(void * handle);

//      clear memory data buffer
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      none
//
// remarks
//      none
PRINTERLIBS_API void CaysnPos_ClearMemoryData(void * handle);


PRINTERLIBS_API int CaysnPos_SetWritedEvent(void * handle, const on_bytes_writed event, void *private_data);


PRINTERLIBS_API int CaysnPos_SetReadedEvent(void * handle, const on_bytes_readed event, void *private_data);


PRINTERLIBS_API int CaysnPos_SetClosedEvent(void * handle, const on_port_closed event, void *private_data);

//      Write data to port
//
// handle 
//      Port handle, returned by OpenXXX
//
// buffer 
//      buffer
//
// count 
//      buffer length
//
// timeout 
//      Timeout ms
//
// return 
//      return bytes writted. or return -1 means failed
PRINTERLIBS_API int CaysnPos_Write(void * handle, const unsigned char *buffer, unsigned int count, unsigned int timeout);

//      Receive data from port
//
// handle 
//      Port handle, returned by OpenXXX
//
// buffer 
//      buffer
//
// count 
//      buffer length
//
// timeout 
//      Timeout ms
//
// return 
//      return bytes readed. or return -1 means failed
PRINTERLIBS_API int CaysnPos_Read(void * handle, unsigned char *buffer, unsigned int count, unsigned int timeout);

//      Receive data from port
//
// handle 
//      Port handle, returned by OpenXXX
//
// buffer 
//      buffer
//
// count 
//      buffer length
//
// timeout 
//      Timeout ms
//
// breakByte
//      break read byte
//
// return 
//      return bytes readed. or return -1 means failed
PRINTERLIBS_API int CaysnPos_ReadUntilByte(void * handle, unsigned char *buffer, unsigned int count, unsigned int timeout, unsigned char breakByte);

//      Skip receive buffer
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      none
PRINTERLIBS_API void CaysnPos_SkipAvailable(void * handle);

//      Close Port
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      none
PRINTERLIBS_API void CaysnPos_Close(void * handle);

//      Query and wait for the printer buffer empty
//
// handle 
//      Port handle, returned by OpenXXX
//
// timeout 
//      timeout ms
//
// return 
//      return whether the buffer is empty. the value defined as follow:
//      value define
//      0     printer buffer is empty
//      -1    the port is closed
//      -2    write failed
//      -3    read failed
//      -4    printer buffer is not empty
PRINTERLIBS_API int CaysnPos_QueryPrinterBufferEmpty(void * handle, unsigned int timeout);

//      real time query printer status(drawer, paper, error)
//
// handle 
//      Port handle, returned by OpenXXX
//
// timeout 
//      timeout ms
//
// return 
//      return printer status, or -1 if query status failed
//      can access detailed status information via macro definition
PRINTERLIBS_API int CaysnPos_QueryPrinterStatus(void * handle, unsigned int timeout);

//      Query print result
//
// handle 
//      Port handle, returned by OpenXXX
//
// timeout 
//      timeout ms
//
// return 
//      return value indicate the print result.
//      the value defined as follow:
//      value define
//      0     print success
//      -1    the port is closed
//      -2    write failed
//      -3    read failed
//      -4    printer no response
//      -102    printer is offline
//      -103    printer is nopaper
//      -101    other error
PRINTERLIBS_API int CaysnPos_QueryPrintResult(void * handle, unsigned int timeout);

//      Turn on cashbox
//
// handle 
//      Port handle, returned by OpenXXX
//
// nDrawerIndex 
//      Cashbox no, value are defined as follow:
//      value      define
//        0      Cashbox pin 2
//        1      Cashbox pin 5
//
// nHighLevelTime 
//      Cashbox pulse high potential ms time
//
// nLowLevelTime 
//      Cashbox pulse low potential ms time
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_KickOutDrawer(void * handle, int nDrawerIndex, int nHighLevelTime, int nLowLevelTime);

//      Buzzer call
//
// handle 
//      Port handle, returned by OpenXXX
//
// nBeepCount
//      Calling times
//
// nBeepMs
//      Calling time ms, value range is [100,900], flour to 100 milliseconds.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_Beep(void * handle, int nBeepCount, int nBeepMs);

//      feed to cutter position and half cut paper
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_FeedAndHalfCutPaper(void * handle);

//      full cut paper
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_FullCutPaper(void * handle);

//      half cut paper
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_HalfCutPaper(void * handle);

//      reset printer, clear settings
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_ResetPrinter(void * handle);

//      set printer
//
// handle 
//      Port handle, returned by OpenXXX
//
// setType
//      set type
//
// buffer 
//      buffer
//
// count 
//      buffer length
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetPrinter(void * handle, int setType, const void *buffer, unsigned int count);

//      set print speed (some printer suppert)
//
// handle 
//      Port handle, returned by OpenXXX
//
// nSpeed
//      print speed in mm/s
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetPrintSpeed(void * handle, int nSpeed);

//      set print density (some printer suppert)
//
// handle 
//      Port handle, returned by OpenXXX
//
// nDensity
//      the print density, the value defined as follow:
//      value define
//      0     light
//      1     normal
//      2     dark
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetPrintDensity(void * handle, PrintDensity nDensity);

//      set print heat para (some printer suppert)
//
// handle 
//      Port handle, returned by OpenXXX
//
// nMaxHeatDots
//      max heat dots
//
// nHeatOnTime
//      heat on time(us)
//
// nHeatOffTime
//      heat off time(us)
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetPrintHeatPara(void * handle, int nMaxHeatDots, int nHeatOnTime, int nHeatOffTime);

//      printer print self test page
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintSelfTestPage(void * handle);

//      set print movement unit
//
// handle 
//      Port handle, returned by OpenXXX
//
// nHorizontalMovementUnit
//      horizontal movement unit
//
// nVerticalMovementUnit
//      vertical movement unit
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if set movement unit to 200, 1mm means 8point.
PRINTERLIBS_API int CaysnPos_SetMovementUnit(void * handle, int nHorizontalMovementUnit, int nVerticalMovementUnit);

//      set print area left margin
//
// handle 
//      Port handle, returned by OpenXXX
//
// nLeftMargin
//      print area left margin
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetPrintAreaLeftMargin(void * handle, int nLeftMargin);

//      set print area width
//
// handle 
//      Port handle, returned by OpenXXX
//
// nWidth
//      print area width
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetPrintAreaWidth(void * handle, int nWidth);

//      set horizontal absolute print position
//
// handle 
//      Port handle, returned by OpenXXX
//
// nPosition
//      print position
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetHorizontalAbsolutePrintPosition(void * handle, int nPosition);

//      set horizontal relative print position
//
// handle 
//      Port handle, returned by OpenXXX
//
// nPosition
//      print position
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetHorizontalRelativePrintPosition(void * handle, int nPosition);

//      set print alignment
//
// handle 
//      Port handle, returned by OpenXXX
//
// nAlignment
//      print alignment, value are defined as follow:
//      value define
//      0     align left
//      1     align center
//      2     align right
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetAlignment(void * handle, PosAlignment nAlignment);

//      printer feed numLines
//
// handle 
//      Port handle, returned by OpenXXX
//
// numLines
//      number of lines to feed
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_FeedLine(void * handle, int numLines);

//      printer feed numDots
//
// handle 
//      Port handle, returned by OpenXXX
//
// numDots
//      number of dots to feed
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_FeedDot(void * handle, int numDots);

//       print text
//
// handle 
//      Port handle, returned by OpenXXX
//
// str 
//      the string to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintTextA(void * handle, const char *str);

//       print text
//
// handle 
//      Port handle, returned by OpenXXX
//
// str 
//      the string to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      The function converts the data to UTF8 encoding.
PRINTERLIBS_API int CaysnPos_PrintTextInUTF8W(void * handle, const wchar_t *str);

//       print text
//
// handle 
//      Port handle, returned by OpenXXX
//
// str 
//      the string to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      The function converts the data to GBK encoding.
PRINTERLIBS_API int CaysnPos_PrintTextInGBKW(void * handle, const wchar_t *str);

//       print text
//
// handle 
//      Port handle, returned by OpenXXX
//
// str 
//      the string to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      The function converts the data to BIG5 encoding.
PRINTERLIBS_API int CaysnPos_PrintTextInBIG5W(void * handle, const wchar_t *str);

//       print text
//
// handle 
//      Port handle, returned by OpenXXX
//
// str 
//      the string to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      The function converts the data to ShiftJIS encoding.
PRINTERLIBS_API int CaysnPos_PrintTextInShiftJISW(void * handle, const wchar_t *str);

//       print text
//
// handle 
//      Port handle, returned by OpenXXX
//
// str 
//      the string to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      The function converts the data to EUCKR encoding.
PRINTERLIBS_API int CaysnPos_PrintTextInEUCKRW(void * handle, const wchar_t *str);

//      set text scale
//
// handle 
//      Port handle, returned by OpenXXX
//
// nWidthScale
//      width scale
//
// nHeightScale
//      height scale
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextScale(void * handle, int nWidthScale, int nHeightScale);

//      set ascii text font type
//
// handle 
//      Port handle, returned by OpenXXX
//
// nFontType
//      ascii text font type, values defined as follow:
//      value define
//      0     FontA (12x24)
//      1     FontB (9x17)
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetAsciiTextFontType(void * handle, AsciiTextFontType nFontType);

//      set text bold
//
// handle 
//      Port handle, returned by OpenXXX
//
// nBold
//      text bold , values defined as follow:
//      value define
//      0     don't bold
//      1     bold
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextBold(void * handle, int nBold);

//      set text underline
//
// handle 
//      Port handle, returned by OpenXXX
//
// nUnderline
//      text underline, values defined as follow:
//      value define
//      0     no underline
//      1     1 point underline
//      2     2 point underline
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextUnderline(void * handle, TextUnderline nUnderline);

//      set text upside down
//
// handle 
//      Port handle, returned by OpenXXX
//
// nUpsideDown
//      upside down, values defined as follow:
//      value define
//      0     print text dont't upside down 
//      1     print text upside down
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextUpsideDown(void * handle, int nUpsideDown);

//      set text black and white reverse
//
// handle 
//      Port handle, returned by OpenXXX
//
// nWhiteOnBlack
//      black and white reverse, values defined as follow: 
//      value define
//      0     print text normal
//      1     print text black and white reverse
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextWhiteOnBlack(void * handle, int nWhiteOnBlack);

//      set text rotate 90 print
//
// handle 
//      Port handle, returned by OpenXXX
//
// nRotate
//      set text rotate, value defined as follow:
//      value define
//      0     print normal
//      1     text print rotate 90 degree
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextRotate(void * handle, int nRotate);

//      set line height
//
// handle 
//      Port handle, returned by OpenXXX
//
// nLineHeight
//      line height, value range is [1,255]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetTextLineHeight(void * handle, int nLineHeight);

//      set ascii text char right spacing
//
// handle 
//      Port handle, returned by OpenXXX
//
// nSpacing
//      right spacing, range is [1,255]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetAsciiTextCharRightSpacing(void * handle, int nSpacing);

//      set kanji text char left spacing and right spacing
//
// handle 
//      Port handle, returned by OpenXXX
//
// nLeftSpacing
//      left spacing, range is [1,255]
//
// nRightSpacing
//      right spacing, range is [1,255]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetKanjiTextCharSpacing(void * handle, int nLeftSpacing, int nRightSpacing);

//      set printer to single byte mode
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetSingleByteMode(void * handle);

//      set print speed (some printer suppert)
//
// handle 
//      Port handle, returned by OpenXXX
//
// nCharacterSet
//      character set, range is [0, 15]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetCharacterSet(void * handle, CharacterSet nCharacterSet);

//      set character codepage
//
// handle 
//      Port handle, returned by OpenXXX
//
// nCharacterCodepage
//      character codepage, range is [0,255]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetCharacterCodepage(void * handle, CharacterCodepage nCharacterCodepage);

//      set printer to multi byte mode
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetMultiByteMode(void * handle);

//      set printer multi byte encoding
//
// handle 
//      Port handle, returned by OpenXXX
//
// nEncoding
//      multi byte encoding, values defined as follow:
//      value define
//      0     GBK
//      1     UTF8
//      3     BIG5
//      4     SHIFT-JIS
//      5     EUC-KR
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetMultiByteEncoding(void * handle, MultiByteModeEncoding nEncoding);

//      set user character pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// ch
//      the char to define, value range is [0x20, 0x7E]
//
// pszFile
//      image file path
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image size is not 12x24, will scale to 12x24
PRINTERLIBS_API int CaysnPos_SetUserCharacterPatternFromFileA(void * handle, char ch, const char *pszFile);
PRINTERLIBS_API int CaysnPos_SetUserCharacterPatternFromFileW(void * handle, char ch, const wchar_t *pszFile);

//      set user character pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// ch
//      the char to define, value range is [0x20, 0x7E]
//
// data 
//      image data
//
// data_size 
//      image data size
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image size is not 12x24, will scale to 12x24
PRINTERLIBS_API int CaysnPos_SetUserCharacterPatternFromData(void * handle, char ch, const unsigned char *data, unsigned int data_size);

//      set user character pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// ch
//      the char to define, value range is [0x20, 0x7E]
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      if image size is not 12x24, will scale to 12x24
PRINTERLIBS_API int CaysnPos_SetUserCharacterPatternFromPixels(void * handle, char ch, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format);

//      clear user character pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// ch
//      the char to clear user pattern, value range is [0x20, 0x7E]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_ClearUserCharacterPattern(void * handle, char ch);

//      set if use user character
//
// handle 
//      Port handle, returned by OpenXXX
//
// enable
//      use or not
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetUserCharacterEnable(void * handle, int enable);

//      set user kanji pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// c1
//      user kanji code byte 1
//
// c2
//      user kanji code byte 2
//
// pszFile
//      image file path
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image size is not 24x24, will scale to 24x24
PRINTERLIBS_API int CaysnPos_SetUserKanjiPatternFromFileA(void * handle, unsigned char c1, unsigned char c2, const char *pszFile);
PRINTERLIBS_API int CaysnPos_SetUserKanjiPatternFromFileW(void * handle, unsigned char c1, unsigned char c2, const wchar_t *pszFile);

//      set user kanji pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// c1
//      user kanji code byte 1
//
// c2
//      user kanji code byte 2
//
// data 
//      image data
//
// data_size 
//      image data size
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image size is not 24x24, will scale to 24x24
PRINTERLIBS_API int CaysnPos_SetUserKanjiPatternFromData(void * handle, unsigned char c1, unsigned char c2, const unsigned char *data, unsigned int data_size);

//      set user kanji pattern
//
// handle 
//      Port handle, returned by OpenXXX
//
// c1
//      user kanji code byte 1
//
// c2
//      user kanji code byte 2
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// return 
//      If command is written successfully, it returns true else it returns false.
// 
// remarks
//      if image size is not 24x24, will scale to 24x24
PRINTERLIBS_API int CaysnPos_SetUserKanjiPatternFromPixels(void * handle, unsigned char c1, unsigned char c2, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format);

//      print 1D barcode
//
// handle 
//      Port handle, returned by OpenXXX
//
// nBarcodeType 
//      barcode type
//      values are defined as follow:
//      value    type
//      0x41     UPC-A
//      0x42     UPC-E
//      0x43     EAN13
//      0x44     EAN8
//      0x45     CODE39
//      0x46     ITF
//      0x47     CODABAR
//      0x48     CODE93
//      0x49     CODE128
//
// str 
//      the barcode data to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintBarcodeA(void * handle, PosBarcodeType nBarcodeType, const char *str);
PRINTERLIBS_API int CaysnPos_PrintBarcodeW(void * handle, PosBarcodeType nBarcodeType, const wchar_t *str);

//      set barcode and qrcode unit width
//
// handle 
//      Port handle, returned by OpenXXX
//
// nBarcodeUnitWidth
//      It assigns the code basic element width. range is [2,6]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBarcodeUnitWidth(void * handle, int nBarcodeUnitWidth);

//      set barcode height
//
// handle 
//      Port handle, returned by OpenXXX
//
// nBarcodeHeight 
//      Barcode height, range is [1,255]
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBarcodeHeight(void * handle, int nBarcodeHeight);

//      set barcode readable text font type
//
// handle 
//      Port handle, returned by OpenXXX
//
// nFontType
//      It assigns HRI(Human Readable Interpretation) character font types.
//      value type
//      0     standard ASCII
//      1     small ASCII
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBarcodeReadableTextFontType(void * handle, BarcodeReadableTextFontType nFontType);

//      set barcode readable text print position
//
// handle 
//      Port handle, returned by OpenXXX
//
// nTextPosition
//      barcode readable text position, value range is [0, 3].
//      value defined as follow:
//      value define
//      0     don't show readable text
//      1     show readable text below barcode
//      2     show readable text above barcode
//      3     show readable text above and below barcode
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBarcodeReadableTextPosition(void * handle, BarcodeReadableTextPosition nTextPosition);

//      print qrcode
//
// handle 
//      Port handle, returned by OpenXXX
//
// nVersion 
//      Assign charater version. The value range is:[0,16]
//      When version is 0, printer caculates version number according to character set automatically.
//
// nECCLevel 
//      Assign error correction level.
//      The value range is: [1, 4].
//      Definitios are as below:
//      ECC error correction level
//      1   L:7%, low error correction, much data.
//      2   M:15%, medium error correction
//      3   Q:optimize error correction
//      4   H:30%, the highest error correction, less data.
//
// str 
//      the qrcode data to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintQRCodeA(void * handle, int nVersion, QRCodeECC nECCLevel, const char *str);
PRINTERLIBS_API int CaysnPos_PrintQRCodeW(void * handle, int nVersion, QRCodeECC nECCLevel, const wchar_t *str);

//      print qrcode
//
// handle 
//      Port handle, returned by OpenXXX
//
// nQRCodeUnitWidth 
//     QRCode code block width, the value range is [1, 16]
//
// nECCLevel 
//      Assign error correction level.
//      The value range is: [1, 4].
//      Definitios are as below:
//      ECC error correction level
//      1   L:7%, low error correction, much data.
//      2   M:15%, medium error correction
//      3   Q:optimize error correction
//      4   H:30%, the highest error correction, less data.
//
// str 
//      the qrcode data to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintQRCodeUseEpsonCmdA(void * handle, int nQRCodeUnitWidth, QRCodeECC nECCLevel, const char *str);
PRINTERLIBS_API int CaysnPos_PrintQRCodeUseEpsonCmdW(void * handle, int nQRCodeUnitWidth, QRCodeECC nECCLevel, const wchar_t *str);

//      print 2 qrcode
//
// handle 
//      Port handle, returned by OpenXXX
//
// nQRCodeUnitWidth 
//     QRCode code block width, the value range is [1, 8]
//
// nQR1Position
// nQR2Position
//      QRCode position
//
// nQR1Version 
// nQR2Version 
//      Assign charater version. The value range is:[0,16]
//      When version is 0, printer caculates version number according to character set automatically.
//
// nQR1ECCLevel 
// nQR2ECCLevel 
//      Assign error correction level.
//      The value range is: [1, 4].
//      Definitios are as below:
//      ECC error correction level
//      1   L:7%, low error correction, much data.
//      2   M:15%, medium error correction
//      3   Q:optimize error correction
//      4   H:30%, the highest error correction, less data.
//
// strQR1 
// strQR2
//      the qrcode data to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintDoubleQRCodeA(void * handle, int nQRCodeUnitWidth, int nQR1Position, int nQR1Version, QRCodeECC nQR1ECCLevel, const char *strQR1, int nQR2Position, int nQR2Version, QRCodeECC nQR2ECCLevel, const char *strQR2);
PRINTERLIBS_API int CaysnPos_PrintDoubleQRCodeW(void * handle, int nQRCodeUnitWidth, int nQR1Position, int nQR1Version, QRCodeECC nQR1ECCLevel, const wchar_t *strQR1, int nQR2Position, int nQR2Version, QRCodeECC nQR2ECCLevel, const wchar_t *strQR2);

//      print pdf417 barcode
//
// handle 
//      Port handle, returned by OpenXXX
//
// columnCount
//      column count, range is [0,30]
//
// rowCount
//      row count, range is 0,[3,90]
//
// unitWidth
//      module unit width, range is [2,8]
//
// rowHeight 
//      row height, range is [2,8]
//
// nECCLevel 
//      ecc level, range is [0,8]
//
// dataProcessingMode
//      data processing mode, 0 select standard PDF417, 1 select cutoff PDF417
//
// str 
//      the pdf417 data to print
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintPDF417BarcodeUseEpsonCmdA(void * handle, int columnCount, int rowCount, int unitWidth, int rowHeight, int nECCLevel, int dataProcessingMode, const char *str);
PRINTERLIBS_API int CaysnPos_PrintPDF417BarcodeUseEpsonCmdW(void * handle, int columnCount, int rowCount, int unitWidth, int rowHeight, int nECCLevel, int dataProcessingMode, const wchar_t *str);

//      get image width and height
//
// pszFile 
//      image file path
//
// depth
//      image depth
//
// width 
//      image width
//
// height 
//      image height
//
// return 
//      The return value indicates whether a successful. return of true indicates success, or false indicates failure
PRINTERLIBS_API int CaysnPos_GetImageSizeFromFileA(const char *pszFile, int *depth, int *width, int *height);
PRINTERLIBS_API int CaysnPos_GetImageSizeFromFileW(const wchar_t *pszFile, int *depth, int *width, int *height);

//      Get the image width and height from the image data
//
// data 
//      image data
//
// data_size 
//      image data size
//
// depth
//      image depth
//
// width 
//      image width
//
// height 
//      image height
//
// return 
//      The return value indicates whether a successful. return of true indicates success, or false indicates failure
// 
// remarks
//      Supports access to mainstream image format information, including but not limited to BMP,JPG,PNG, etc.
PRINTERLIBS_API int CaysnPos_GetImageSizeFromData(const unsigned char *data, unsigned int data_size, int *depth, int *width, int *height);

//      print image
//
// handle 
//      Port handle, returned by OpenXXX
//
// dstw 
//      the width to print
//
// dsth 
//      the height to print
//
// pszFile 
//      image file path
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRasterImageFromFileA(void * handle, int dstw, int dsth, const char *pszFile, ImageBinarizationMethod binaryzation_method);
PRINTERLIBS_API int CaysnPos_PrintRasterImageFromFileW(void * handle, int dstw, int dsth, const wchar_t *pszFile, ImageBinarizationMethod binaryzation_method);

//      print image (data can be readed from file)
//
// handle 
//      Port handle, returned by OpenXXX
//
// dstw 
//      the width to print
//
// dsth 
//      the height to print
//
// data 
//      image data
//
// data_size 
//      image data size
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRasterImageFromData(void * handle, int dstw, int dsth, const unsigned char *data, unsigned int data_size, ImageBinarizationMethod binaryzation_method);

//      print image pixels
//
// handle 
//      Port handle, returned by OpenXXX
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRasterImageFromPixels(void * handle, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format, ImageBinarizationMethod binaryzation_method);

//      print image
//
// handle 
//      Port handle, returned by OpenXXX
//
// dstw 
//      the width to print
//
// dsth 
//      the height to print
//
// pszFile 
//      image file path
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// compress_method
//      print data compress method, values are defined as follow
//      value define
//      0     no compress
//      1     compress level 1
//      2     compress level 2
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRasterImageWithCompressFromFileA(void * handle, int dstw, int dsth, const char *pszFile, ImageBinarizationMethod binaryzation_method, ImageCompressionMethod compress_method);
PRINTERLIBS_API int CaysnPos_PrintRasterImageWithCompressFromFileW(void * handle, int dstw, int dsth, const wchar_t *pszFile, ImageBinarizationMethod binaryzation_method, ImageCompressionMethod compress_method);

//      print image (data can be readed from file)
//
// handle 
//      Port handle, returned by OpenXXX
//
// dstw 
//      the width to print
//
// dsth 
//      the height to print
//
// data 
//      image data
//
// data_size 
//      image data size
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// compress_method
//      print data compress method, values are defined as follow
//      value define
//      0     no compress
//      1     compress level 1
//      2     compress level 2
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRasterImageWithCompressFromData(void * handle, int dstw, int dsth, const unsigned char *data, unsigned int data_size, ImageBinarizationMethod binaryzation_method, ImageCompressionMethod compress_method);

//      print image pixels
//
// handle 
//      Port handle, returned by OpenXXX
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// compress_method
//      print data compress method, values are defined as follow
//      value define
//      0     no compress
//      1     compress level 1
//      2     compress level 2
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRasterImageWithCompressFromPixels(void * handle, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format, ImageBinarizationMethod binaryzation_method, ImageCompressionMethod compress_method);

//      fill image to current line
//
// handle 
//      Port handle, returned by OpenXXX
//
// pszFile 
//      image file path
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image is higher than 24, will scale to 24 pixel print.
//      if image is no more than 24, will padding to 24 pixel print.
PRINTERLIBS_API int CaysnPos_FillDotImageToCurrentLineFromFileA(void * handle, const char *pszFile, ImageBinarizationMethod binaryzation_method);
PRINTERLIBS_API int CaysnPos_FillDotImageToCurrentLineFromFileW(void * handle, const wchar_t *pszFile, ImageBinarizationMethod binaryzation_method);

//      fill image to current line
//
// handle 
//      Port handle, returned by OpenXXX
//
// data 
//      image data
//
// data_size 
//      image data size
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image is higher than 24, will scale to 24 pixel print.
//      if image is no more than 24, will padding to 24 pixel print.
PRINTERLIBS_API int CaysnPos_FillDotImageToCurrentLineFromData(void * handle, const unsigned char *data, unsigned int data_size, ImageBinarizationMethod binaryzation_method);

//      fill image to current line
//
// handle 
//      Port handle, returned by OpenXXX
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image is higher than 24, will scale to 24 pixel print.
//      if image is no more than 24, will padding to 24 pixel print.
PRINTERLIBS_API int CaysnPos_FillDotImageToCurrentLineFromPixels(void * handle, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format, ImageBinarizationMethod binaryzation_method);

//      print image
//
// handle 
//      Port handle, returned by OpenXXX
//
// nPosition
//      print position
//
// dstw 
//      the width to print
//
// dsth 
//      the height to print
//
// pszFile 
//      image file path
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image height is not a multiple of 24, will padding height to a multiple of 24 pixel print.
PRINTERLIBS_API int CaysnPos_PrintDotImageSpecifyHorizontalPositionFromFileA(void * handle, int nPosition, int dstw, int dsth, const char *pszFile, ImageBinarizationMethod binaryzation_method);
PRINTERLIBS_API int CaysnPos_PrintDotImageSpecifyHorizontalPositionFromFileW(void * handle, int nPosition, int dstw, int dsth, const wchar_t *pszFile, ImageBinarizationMethod binaryzation_method);

//      print image
//
// handle 
//      Port handle, returned by OpenXXX
//
// nPosition
//      print position
//
// dstw 
//      the width to print
//
// dsth 
//      the height to print
//
// data 
//      image data
//
// data_size 
//      image data size
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image height is not a multiple of 24, will padding height to a multiple of 24 pixel print.
PRINTERLIBS_API int CaysnPos_PrintDotImageSpecifyHorizontalPositionFromData(void * handle, int nPosition, int dstw, int dsth, const unsigned char *data, unsigned int data_size, ImageBinarizationMethod binaryzation_method);

//      print image
//
// handle 
//      Port handle, returned by OpenXXX
//
// nPosition
//      print position
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
//
// remarks
//      if image height is not a multiple of 24, will padding height to a multiple of 24 pixel print.
PRINTERLIBS_API int CaysnPos_PrintDotImageSpecifyHorizontalPositionFromPixels(void * handle, int nPosition, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format, ImageBinarizationMethod binaryzation_method);

//      define the nv image
//
// handle 
//      Port handle, returned by OpenXXX
//
// count 
//      number of image file
//
// pszFiles 
//      image file path
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetNVImageFromFilesA(void * handle, unsigned int count, const char **pszFiles);
PRINTERLIBS_API int CaysnPos_SetNVImageFromFilesW(void * handle, unsigned int count, const wchar_t **pszFiles);

//      define the nv image
//
// handle 
//      Port handle, returned by OpenXXX
//
// count 
//      number of image data
//
// pdata 
//      image data
//
// pdata_size 
//      image data size
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetNVImageFromDatas(void * handle, unsigned int count, unsigned char **pdata, unsigned int *pdata_size);

//      print nv image
//
// handle 
//      Port handle, returned by OpenXXX
//
// no 
//      nv image no. first image no is 1, second image no is 2...
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintNVImage(void * handle, int no);

//      clear nv image
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_ClearNVImage(void * handle);

//      define the ram image
//
// handle 
//      Port handle, returned by OpenXXX
//
// pszFile
//      image file path
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetRAMImageFromFileA(void * handle, int dstw, int dsth, const char *pszFile, ImageBinarizationMethod binaryzation_method);
PRINTERLIBS_API int CaysnPos_SetRAMImageFromFileW(void * handle, int dstw, int dsth, const wchar_t *pszFile, ImageBinarizationMethod binaryzation_method);

//      define the ram image
//
// handle 
//      Port handle, returned by OpenXXX
//
// data 
//      image data
//
// data_size 
//      image data size
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetRAMImageFromData(void * handle, int dstw, int dsth, const unsigned char *data, unsigned int data_size, ImageBinarizationMethod binaryzation_method);

//      define the ram image
//
// handle 
//      Port handle, returned by OpenXXX
//
// img_data 
//      image pixels data
//
// img_datalen
//      image pixels data length
//
// img_width 
//      image pixel width
//
// img_height 
//      image pixel height
//
// img_stride 
//      image horizontal stirde. means bytes per line.
//
// img_format
//      image pixel data format, values are defined as follow
//      value define
//      1     mono 
//      2     monolsb 
//      3     gray
//      4     r.g.b in byte-ordered
//      5     b.g.r in byte-ordered
//      6     a.r.g.b in byte-ordered
//      7     r.g.b.a in byte-ordered
//      8     a.b.g.r in byte-ordered
//      9     b.g.r.a in byte-ordered
//
// binaryzation_method
//      image binaryzation method. 0 means use dithering, 1 means use thresholding.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetRAMImageFromPixels(void * handle, const unsigned char *img_data, unsigned int img_datalen, int img_width, int img_height, int img_stride, ImagePixelsFormat img_format, ImageBinarizationMethod binaryzation_method);

//      print RAM image
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintRAMImage(void * handle);

//      print one horizontal line
//
// handle 
//      Port handle, returned by OpenXXX
//
// nLineStartPosition
//      line start position
//
// nLineEndPosition
//      line end position
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintHorizontalLine(void * handle, int nLineStartPosition, int nLineEndPosition);

//      print one horizontal line
//
// handle 
//      Port handle, returned by OpenXXX
//
// nLineStartPosition
//      line start position
//
// nLineEndPosition
//      line end position
//
// nLineThickness
//      line thickness
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintHorizontalLineSpecifyThickness(void * handle, int nLineStartPosition, int nLineEndPosition, int nLineThickness);

//      print multiple horizontal lines at one row, multi call can print curve
//
// handle 
//      Port handle, returned by OpenXXX
//
// nLineCount
//      Line count
//
// pLineStartPosition
//      Line start position
//
// pLineEndPosition
//      Line end position
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_PrintMultipleHorizontalLinesAtOneRow(void * handle, int nLineCount, int *pLineStartPosition, int *pLineEndPosition);

//      enable black mark mode
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_EnableBlackMarkMode(void * handle);

//      disable black mark mode
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_DisableBlackMarkMode(void * handle);

//      set black mark max search length(reboot will also valid)
//
// handle 
//      Port handle, returned by OpenXXX
//
// maxFindLength
//      max find length (maxFindLength x 0.125 mm)
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBlackMarkMaxFindLength(void * handle, int maxFindLength);

//      find next black mark
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_FindBlackMark(void * handle);

//      in black mode, set start print position
//
// handle 
//      Port handle, returned by OpenXXX
//
// position
//      position > 0 means feed, position < 0 means feedback. distance is position x 0.125 mm.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBlackMarkPaperPrintPosition(void * handle, int position);

//      in black mark mode, set cut position
//
// handle 
//      Port handle, returned by OpenXXX
//
// position
//      position > 0 means feed, position < 0 means feedback. distance is position x 0.125 mm.
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_SetBlackMarkPaperCutPosition(void * handle, int position);

//      full cut paper
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_FullCutBlackMarkPaper(void * handle);

//      half cut paper
//
// handle 
//      Port handle, returned by OpenXXX
//
// return 
//      If command is written successfully, it returns true else it returns false.
PRINTERLIBS_API int CaysnPos_HalfCutBlackMarkPaper(void * handle);


#ifdef __cplusplus
}
#endif

#endif

